function self = move(self, weather, target, time, timestep)
%*=+--+=#=+--      UAS Severe Weather Simulation Softeware        --+=#=+--+=#*%
%          Copyright (C) 2013 Regents of the University of Colorado.           %
%                             All Rights Reserved.                             %
%                                                                              %
%    This program is free software: you can redistribute it and/or modify      %
%    it under the terms of the GNU General Public License version 2 as         %
%    published by the Free Software Foundation.                                %
%                                                                              %
%    This program is distributed in the hope that it will be useful,           %
%    but WITHOUT ANY WARRANTY; without even the implied warranty of            %
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             %
%    GNU General Public License for more details.                              %
%                                                                              %
%    You should have received a copy of the GNU General Public License         %
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.     %
%                                                                              %
%           Jack Elston                                                        %
%           elstonj@colorado.edu                                               %
%                                                                              %
%*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*%

  [self.input,self.flight_computer] = getOutput(self.flight_computer,self,weather,target,time);

  vector = weather(time, self.pos);
  u = vector(1);
  v = vector(2);
  w = vector(3);
  rain = vector(4);
  hail = vector(5);

  hdg=-(atan2(u,v)-pi/2);
  if (hdg < 0)    hdg=hdg+2*pi; end
  if (hdg > 2*pi) hdg=hdg-2*pi; end
  mag = norm([u,v]);

  self.log.sonde      = [self.log.sonde;[self.pos,rain,hdg,mag]];

  %u = 0;
  %v = 0;
  w = 0;

  self.pos(1)=self.pos(1)+timestep*(self.input(1)*cos(-self.euler(3)+pi/2)+u);
  self.pos(2)=self.pos(2)+timestep*(self.input(1)*sin(-self.euler(3)+pi/2)+v);
  self.pos(3)=self.pos(3)+timestep*w;
  self.euler(3)=self.euler(3)+timestep*self.input(2);

  if self.euler(3) < 0
    self.euler(3)=self.euler(3)+2*pi;
  end
  if self.euler(3) > 2*pi
    self.euler(3)=self.euler(3)-2*pi;
  end

  err = norm(self.nextpos - self.pos);

  %expected position%
  nextinput = getOutput(self.flight_computer,self,weather,target,time);

  my_time = floor(time/60) * 60;
  %vector = weather(my_time, self.pos);
  %u = vector(1);
  %v = vector(2);
  %w = vector(3);
  %rain = vector(4);
  %hail = vector(5);
  u = 0;
  v = 0;
  w = 0;
  rain = 0;

  self.nextpos(1)=self.pos(1)+timestep*(nextinput(1)*cos(-self.euler(3)+pi/2)+u);
  self.nextpos(2)=self.pos(2)+timestep*(nextinput(1)*sin(-self.euler(3)+pi/2)+v);
  self.nextpos(3)=self.pos(3)+timestep*w;
  %nexteuler(3)=self.euler(3)+timestep*nextinput(2);

  self.log.position   = [self.log.position;self.pos];
  self.log.velocity   = [self.log.velocity;self.vel];
  self.log.euler      = [self.log.euler;self.euler];
  self.log.input      = [self.log.input;self.input];
  self.log.err        = [self.log.err;err];
